package org.vestbjergbyggecenter.TUI;

import java.util.Scanner;

public class MainMenu {
	private static MainMenu instance;
	
	private MainMenu()
	{
		start();
	}
	
	public static MainMenu getInstance()
	{
		if(instance == null)
        {
            instance = new MainMenu();
        }
        return instance;		
	}
	
	public void start()
    {
        boolean exit=false;
        while (!exit)
        {
            int choise = printMainMenu();
            if(choise == 1)
            {
                CustomerMenuUI.getInstance();
            }
            else if(choise == 2)
            {
                OrderMenu.getInstance();
            }
            else if(choise == 3)
            {
                ProductMenu.getInstance();
            }
            else if(choise == 4)
            {
                EmployeeMenu.getInstance();
            }
            else if(choise == 5)
            {
                exit = true;
                writeEnd();
            }
        }
    }
	
    public int printMainMenu()
    {
        Scanner keyboard = new Scanner(System.in);
        //System.out.print('\f');
        System.out.println("***Main Menu***");
        System.out.println("1. Customers");
        System.out.println("2. Orders");
        System.out.println("3. Products");
        System.out.println("4. Employees");
        System.out.println("5. Quit");
        System.out.println("Choice #: ");
        
        int choice = keyboard.nextInt();
        return choice;
    }
	
	private void writeEnd()
    {
        System.out.println("\f *** MainMenu ***");
        System.out.println("\nThe System is shuting down");
        try
        {
        	Thread.sleep(700);
        }
        catch(InterruptedException e)
        {
        	
        }
        System.exit(1);
    }
	
}
